package com.cgmnx.admin.dao.mapper.rbac;

import com.cgmnx.admin.common.bean.Limiter;
import com.cgmnx.admin.common.enums.ValidEnumType;
import com.cgmnx.admin.dao.entity.rbac.RoleEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 权限系统-角色模块
 *
 * @author created on 14-3-1 下午7:42
 * @version $Id$
 */@Repository
public interface RoleMapper {

    /**
     * 保存角色
     *
     * @param entity
     * @return
     */
    int save(RoleEntity entity);

    /**
     * @param entityList
     * @return
     */
    int batchSave(@Param("entityList") List<RoleEntity> entityList);

    /**
     * @param entity
     * @return
     */
    List<RoleEntity> query(@Param("entity") RoleEntity entity);

    /**
     * 更新角色
     *
     * @param entity
     * @return
     */
    int update(RoleEntity entity);

    /**
     * 依据角色ID 删除指定ROLE数据
     *
     * @param list 角色ID
     */
    void updateRoleStatus(@Param("roleIdList") List<Integer> list, @Param("validStatus") ValidEnumType validStatus);

    /**
     * @return
     */
    List<RoleEntity> queryByNameAndValid(@Param("name") String name, @Param("validStatus") ValidEnumType validStatus);


    List<RoleEntity> queryPage(@Param("name") String name, @Param("validStatus") ValidEnumType validStatus, @Param("limiter") Limiter limiter);

    Integer count(@Param("name") String name, @Param("validStatus") ValidEnumType validStatus);

    RoleEntity queryById(@Param("id") Integer id);

    List<RoleEntity> queryAll(@Param("validStatus") ValidEnumType validStatus);

    List<RoleEntity> queryByUserIdList(@Param("userIdList") List<String> userIdList, @Param("validStatus") ValidEnumType validStatus);
}
